//
//  FavouriteWebsiteView.m
//  BaoVn
//
//  Created by Le Anh Tai on 12/20/14.
//  Copyright (c) 2014 Le Anh Tai. All rights reserved.
//

#import "FavouriteWebsiteView.h"

@implementation FavouriteWebsiteView

- (instancetype)init
{
    if (self = [super init])
    {
        [self.createdDateLabel removeFromSuperview];
    }
    
    return self;
}

- (void)loadData:(NSManagedObject *)data
{
    self.data = data;
    
    self.imageView.image = [UIImage imageNamed:[data valueForKey:ICON_KEY]];
    self.titleLabel.text = [data valueForKey:TITLE_KEY];
    self.descriptionLabel.text = [data valueForKey:DESCRIPTION_KEY];
}

- (void)setFrame:(CGRect)frame
{
    [super setFrame:frame];
    
    if (CGSizeEqualToSize(frame.size, CGSizeZero))
    {
        return;
    }
    
    NSInteger left = self.marginLeft;
    NSInteger widImage = self.height - self.marginTop - self.marginBottom;
    
    self.imageView.hidden = NO;
    self.imageView.frame = RECT(left, self.marginTop, widImage, widImage);
//    self.imageView.layer.cornerRadius = self.imageView.height/2;
//    self.imageView.layer.borderWidth = 0;
    
    left = self.imageView.right + self.paddingImageAndContent;
    
    
    self.titleLabel.frame = RECT(left, self.marginTop, self.width - left - self.marginRight, 100);
    [self.titleLabel sizeToFit];
    
    self.descriptionLabel.frame = RECT(left, self.titleLabel.bottom, self.width - left - self.marginRight, self.height - self.marginBottom - self.titleLabel.bottom);
}
@end
